package com.jzx.provider.cv.repository;

import com.jzx.provider.cv.model.CurrentInfo;
import com.jzx.provider.cv.model.Cv;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
public interface CvRepository extends JpaRepository<Cv, Long> {
    @Query(nativeQuery = true, value = "select * from t_cv where is_index='0' limit 0,?1")
    List<Cv> getCvByPage(int count);

    @Modifying
    @Query(nativeQuery = true, value = "update t_cv set sex=:#{#cv.sex}," +
            "birth_day=:#{#cv.birthDay},tel=:#{#cv.tel},email=:#{#cv.email}," +
            "nationality=:#{#cv.nationality},marital_status=:#{#cv.maritalStatus}," +
            "census_register=:#{#cv.censusRegister},political=:#{#cv.political},is_index=:#{#cv.isIndex}," +
            "update_time=:#{#cv.updateTime} where id=:#{#cv.id}")
    void updateCvBasicInfo(Cv cv);

    @Modifying
    @Query(nativeQuery = true, value = "update t_cv set personal=:#{#cv.personal}," +
            "update_time=:#{#cv.updateTime} where id=:#{#cv.id}")
    void updateCvPersonal(Cv cv);

    @Modifying
    @Query(nativeQuery = true, value = "update t_cv set additional=:#{#cv.additional}," +
            "update_time=:#{#cv.updateTime} where id=:#{#cv.id}")
    void updateCvAdditional(Cv cv);

    @Modifying
    @Query(nativeQuery = true, value = "update t_cv set professional=:#{#cv.professional}," +
            "update_time=:#{#cv.updateTime} where id=:#{#cv.id}")
    void updateCvProfessional(Cv cv);
}
